<?php

namespace app\admin\service;

use app\admin\dao\TradeDao;
use app\admin\model\UM as UM;
use app\common\model\Trade;
use ShidianUtil\Utils\TimeUtil;

/**
 * Class TradeStatisticsService
 * @package app\admin\service
 */
class TradeStatisticsService
{
    // dao
    private TradeDao $tradeDao;

    public function __construct(TradeDao $tradeDao)
    {
        $this->tradeDao = $tradeDao;
    }

    /**
     * 案源订单统计
     * @param UM|null $user
     * @param $categoryId
     * @param $provinceId
     * @param $cityId
     * @param $status
     * @param $startTime
     * @param $endTime
     * @param $kw
     * @return array
     */
    public function read(?UM $user, $categoryId, $provinceId, $cityId, $status, $startTime, $endTime, $kw): array
    {
        if(is_numeric($endTime)){
            $endTime = TimeUtil::stamp(TimeUtil::DAY, $endTime, false);
        }
        return $this->tradeDao->statisticsListLawCases($categoryId, $provinceId, $cityId, $status, $startTime, $endTime, $kw);
    }

}
